<?php

namespace app\admin\command;

use app\common\util\Tools;
use think\console\Input;
use think\console\Output;
use think\facade\Log;

class UserTest extends CommonTest
{

    //再命令窗口中执行“php think interface-UserTest”
    protected function configure()
    {
        $this->setName('interface-UserTest')
            ->setDescription('接口测试');
    }

    public function execute(Input $input, Output $output)
    {
        parent::execute($input, $output);

        /** 客户管理 */
        //Route::post('admin/user/getPageList', 'admin/user/getPageList');                                                        // 获取用户列表数组，分页
        $data = Tools::curl($this->url . "admin/user/getPageList", json_encode(["token" => "$this->token"]));
        Log::write("post". var_export($data,true));
        echo $data . "\n\n";

        //Route::post('admin/user/getDetailsById', 'admin/user/getInfo');                                                         // 用户详情
        $data = Tools::curl($this->url . "admin/user/getDetailsById", json_encode(["token" => "$this->token", "id" => 1]));
        Log::write("post". var_export($data,true));
        echo $data . "\n\n";

        //Route::post('admin/user/update', 'admin/user/update');                                                                  // 更新客户
        $data = Tools::curl($this->url . "admin/user/update", json_encode(["token" => "$this->token", "id" => 1]));
        Log::write("post". var_export($data,true));
        echo $data . "\n\n";

        //Route::post('admin/user/update', 'admin/user/update');                                                                  // 更新客户类型
        $data = Tools::curl($this->url . "admin/user/update/status", json_encode(["token" => "$this->token", "id" => 1, "status" => 6]));
        Log::write("post". var_export($data,true));
        echo $data . "\n\n";

        //Route::post('admin/user/del', 'admin/user/del');                                                                        // 删除客户
        $data = Tools::curl($this->url . "admin/user/del", json_encode(["token" => "$this->token", "id" => 1]));
        Log::write("post". var_export($data,true));
        echo $data . "\n\n";
    }
}
